import {
    x as h,
    r as J,
    c as X,
    i,
    o as r,
    a as x,
    m as e,
    l as t,
    k as f,
    b as V,
    e as m,
    t as w,
    u as M,
    F as O,
    j as H,
    T as Y,
    O as R,
    P as F,
    U as Z,
    Q,
    w as S,
    d as A,
    B as y,
    A as ee,
    H as G
} from "./index-abba05ce.js";

const te = {style: {width: "100%", background: "#f8f8f8", padding: "5px 11px", "border-radius": "4px"}}, le = {
        style: {
            float: "left",
            width: "400px",
            overflow: "hidden",
            "text-overflow": "ellipsis",
            "white-space": "nowrap"
        }
    }, ae = {style: {float: "right", color: "var(--el-text-color-secondary)", "font-size": "12px"}},
    ne = {key: 1, style: {width: "100%"}}, oe = {style: {float: "left"}},
    se = {style: {float: "right", color: "var(--el-text-color-secondary)", "font-size": "12px"}},
    de = {key: 1, style: {width: "100%"}}, ie = {
        __name: "edit", emits: ["success", "close"], setup(W, {expose: C, emit: D}) {
            const u = D, v = h(null), p = h(null), _ = h("add"), U = h({user_name: "", content: ""}), a = h({
                id: "",
                user: {type: 2, name: ""},
                dynamic_content: "",
                dynamic_id: "",
                user_id: "",
                content: "",
                reply_user_id: 0,
                reply_comment_id: 0,
                status: 1
            }), I = h({user: [], dynamic: []}), q = J({
                dynamic_id: [{required: !0, message: "请选择一个笔记发布", trigger: "blur"}],
                user_id: [{required: !0, message: "请选择一个用户发布", trigger: "blur"}],
                content: [{required: !0, message: "请填写评论内容", trigger: "blur"}]
            }), N = X(() => {
                if (_.value == "add") return "新增评论";
                if (_.value == "edit") return "编辑评论";
                if (_.value == "reply") return "回复评论"
            }), b = async () => {
                const n = await R.dynamic.select({type: 1});
                I.value = n.data
            }, d = async n => {
                if (_.value == "edit") {
                    const o = await R.comment.detail({id: n.id});
                    a.value = o.data
                } else _.value == "reply" && (a.value.reply_user_id = n.user_id, n.reply_comment_id ? a.value.reply_comment_id = n.reply_comment_id : a.value.reply_comment_id = n.id, a.value.dynamic_id = n.dynamic_id, a.value.dynamic_content = n.dynamic_content, U.value.user_name = n.user.name, U.value.content = n.content)
            }, k = (n = "add") => {
                _.value = n, v.value.open()
            }, B = () => {
                p.value.resetFields(), u("close")
            }, g = async () => {
                var o;
                await ((o = p.value) == null ? void 0 : o.validate());
                let n;
                _.value == "edit" ? n = await R.comment.update(a.value) : n = await R.comment.create(a.value), n.error ? F.msgError(n.msg) : (B(), u("success"), F.msgSuccess(n.msg))
            };
            return b(), C({open: k, setFormData: d}), (n, o) => {
                const $ = i("el-text"), c = i("el-form-item"), E = i("el-option"), T = i("el-select"), K = i("el-input"),
                    P = i("el-radio"), j = i("el-radio-group"), z = i("el-form");
                return r(), x("div", null, [e(Y, {
                    ref_key: "dialogRef",
                    ref: v,
                    title: N.value,
                    async: !0,
                    onConfirm: g,
                    onCancel: B,
                    width: "750px"
                }, {
                    default: t(() => [e(z, {ref_key: "formRef", ref: p, model: a.value, "label-width": "84px", rules: q}, {
                        default: t(() => [_.value == "reply" ? (r(), f(c, {
                            key: 0,
                            label: "回复",
                            class: "mt-2"
                        }, {
                            default: t(() => [V("div", te, [e($, null, {
                                default: t(() => [m(w(U.value.user_name), 1)]),
                                _: 1
                            }), m("： "), e($, {tag: "b"}, {default: t(() => [m(w(U.value.content), 1)]), _: 1})])]), _: 1
                        })) : M("", !0), e(c, {
                            label: "笔记",
                            prop: "dynamic_id"
                        }, {
                            default: t(() => [a.value.user.type == 2 ? (r(), f(T, {
                                key: 0,
                                style: {width: "100%"},
                                modelValue: a.value.dynamic_id,
                                "onUpdate:modelValue": o[0] || (o[0] = l => a.value.dynamic_id = l),
                                placeholder: "点击选择",
                                filterable: "",
                                onChange: o[1] || (o[1] = l => n.$forceUpdate())
                            }, {
                                default: t(() => [(r(!0), x(O, null, H(I.value.dynamic, l => (r(), f(E, {
                                    key: l.id,
                                    label: l.content,
                                    value: l.id
                                }, {
                                    default: t(() => [V("span", le, w(l.content), 1), V("span", ae, " ID：" + w(l.id), 1)]),
                                    _: 2
                                }, 1032, ["label", "value"]))), 128))]), _: 1
                            }, 8, ["modelValue"])) : (r(), x("div", ne, [e(K, {
                                size: "large",
                                modelValue: a.value.dynamic_content,
                                "onUpdate:modelValue": o[2] || (o[2] = l => a.value.dynamic_content = l),
                                disabled: ""
                            }, null, 8, ["modelValue"]), e($, {
                                class: "mx-1",
                                size: "small"
                            }, {default: t(() => [m("普通用户发布内容无法修改编辑")]), _: 1})]))]), _: 1
                        }), e(c, {
                            label: "用户",
                            prop: "user_id"
                        }, {
                            default: t(() => [a.value.user.type == 2 ? (r(), f(T, {
                                key: 0,
                                style: {width: "100%"},
                                modelValue: a.value.user_id,
                                "onUpdate:modelValue": o[3] || (o[3] = l => a.value.user_id = l),
                                placeholder: "点击选择",
                                filterable: "",
                                onChange: o[4] || (o[4] = l => n.$forceUpdate())
                            }, {
                                default: t(() => [(r(!0), x(O, null, H(I.value.user, l => (r(), f(E, {
                                    key: l.id,
                                    label: l.name,
                                    value: l.id
                                }, {
                                    default: t(() => [V("span", oe, w(l.name), 1), V("span", se, " ID：" + w(l.id), 1)]),
                                    _: 2
                                }, 1032, ["label", "value"]))), 128))]), _: 1
                            }, 8, ["modelValue"])) : (r(), x("div", de, [e(K, {
                                size: "large",
                                modelValue: a.value.user.name,
                                "onUpdate:modelValue": o[5] || (o[5] = l => a.value.user.name = l),
                                disabled: ""
                            }, null, 8, ["modelValue"]), e($, {
                                class: "mx-1",
                                size: "small"
                            }, {default: t(() => [m("普通用户发布内容无法修改编辑")]), _: 1})]))]), _: 1
                        }), e(c, {label: "内容", class: "mt-2", prop: "content"}, {
                            default: t(() => [e(K, {
                                size: "large",
                                type: "textarea",
                                modelValue: a.value.content,
                                "onUpdate:modelValue": o[6] || (o[6] = l => a.value.content = l),
                                maxlength: "2000",
                                placeholder: "评论内容",
                                "show-word-limit": "",
                                autosize: {minRows: 4}
                            }, null, 8, ["modelValue"])]), _: 1
                        }), e(c, {label: "状态"}, {
                            default: t(() => [e(j, {
                                modelValue: a.value.status,
                                "onUpdate:modelValue": o[7] || (o[7] = l => a.value.status = l)
                            }, {
                                default: t(() => [e(P, {label: 1, border: ""}, {
                                    default: t(() => [m("正常")]),
                                    _: 1
                                }), e(P, {label: 2, border: ""}, {default: t(() => [m("违法违规")]), _: 1}), e(P, {
                                    label: 3,
                                    border: ""
                                }, {default: t(() => [m("用户删除")]), _: 1})]), _: 1
                            }, 8, ["modelValue"])]), _: 1
                        })]), _: 1
                    }, 8, ["model", "rules"])]), _: 1
                }, 8, ["title"])])
            }
        }
    }, ue = {class: "admin-lists"}, re = {class: "d-flex justify-content-between"}, ce = {class: "mt-3"},
    me = {style: {width: "200px", overflow: "hidden", "text-overflow": "ellipsis", "white-space": "nowrap"}},
    _e = {class: "d-flex justify-content-end mt-4"}, fe = {
        __name: "index", setup(W) {
            const C = h(null), D = h(!1), u = J({status: 99, user_id: "", dynamic_id: "", content: ""}), {
                pager: v,
                getLists: p,
                resetPage: _
            } = Z({fetchFun: R.comment.list, params: u}), U = async () => {
                D.value = !0, await G(), await C.value.open()
            }, a = async (b, d) => {
                D.value = !0, await G(), await C.value.open(b), await C.value.setFormData(d)
            }, I = async b => {
                await F.confirm("确定要删除吗？");
                const d = await R.comment.delete({id: b});
                d.error ? F.msgError(d.msg) : (F.msgSuccess(d.msg), p())
            }, q = () => {
                u.status = 99, u.dynamic_id = "", u.user_id = "", u.content = "", p()
            }, N = (b, d) => {
                u.status = b.props.name, p()
            };
            return p(), (b, d) => {
                const k = i("el-tab-pane"), B = i("el-tabs"), g = i("el-button"), n = i("el-input"), o = i("el-form-item"),
                    $ = i("el-form"), c = i("el-table-column"), E = i("el-avatar"), T = i("el-tag"), K = i("el-table"),
                    P = i("la-pagination"), j = i("el-card"), z = Q("perms"), l = Q("loading");
                return r(), x("div", ue, [e(B, {
                    modelValue: u.status,
                    "onUpdate:modelValue": d[0] || (d[0] = s => u.status = s),
                    class: "demo-tabs",
                    onTabClick: N
                }, {
                    default: t(() => [e(k, {label: "全部", name: 99}), e(k, {
                        label: "待审核",
                        name: 0
                    }), e(k, {label: "正常", name: 1}), e(k, {label: "违法违规", name: 2}), e(k, {
                        label: "用户删除",
                        name: 3
                    })]), _: 1
                }, 8, ["modelValue"]), e(j, {class: "border-none mt-2", shadow: "never"}, {
                    default: t(() => [V("div", re, [S((r(), f(g, {
                        icon: "Plus",
                        type: "primary",
                        onClick: U
                    }, {default: t(() => [m(" 新增 ")]), _: 1})), [[z, ["admin/dynamic.comment/create"]]]), e($, {
                        model: u,
                        inline: ""
                    }, {
                        default: t(() => [e(o, {
                            label: "笔记ID",
                            props: "dynamic_id"
                        }, {
                            default: t(() => [e(n, {
                                modelValue: u.dynamic_id,
                                "onUpdate:modelValue": d[1] || (d[1] = s => u.dynamic_id = s),
                                clearable: "",
                                onKeyup: A(y(_), ["enter"])
                            }, null, 8, ["modelValue", "onKeyup"])]), _: 1
                        }), e(o, {label: "用户ID", props: "user_id"}, {
                            default: t(() => [e(n, {
                                modelValue: u.user_id,
                                "onUpdate:modelValue": d[2] || (d[2] = s => u.user_id = s),
                                clearable: "",
                                onKeyup: A(y(_), ["enter"])
                            }, null, 8, ["modelValue", "onKeyup"])]), _: 1
                        }), e(o, {label: "内容", props: "content"}, {
                            default: t(() => [e(n, {
                                modelValue: u.content,
                                "onUpdate:modelValue": d[3] || (d[3] = s => u.content = s),
                                clearable: "",
                                onKeyup: A(y(_), ["enter"])
                            }, null, 8, ["modelValue", "onKeyup"])]), _: 1
                        }), e(o, {style: {"margin-right": "0"}}, {
                            default: t(() => [e(g, {
                                type: "primary",
                                onClick: y(_),
                                icon: "Search"
                            }, {default: t(() => [m("查询")]), _: 1}, 8, ["onClick"]), e(g, {
                                onClick: q,
                                icon: "Refresh"
                            }, {default: t(() => [m("重置")]), _: 1})]), _: 1
                        })]), _: 1
                    }, 8, ["model"])]), S((r(), x("div", ce, [e(K, {
                        data: y(v).lists,
                        size: "large",
                        "row-key": "id",
                        "default-expand-all": !1,
                        stripe: "",
                        "header-cell-style": {background: "var(--el-bg-color-page)"}
                    }, {
                        default: t(() => [e(c, {
                            prop: "dynamic_id",
                            label: "笔记ID",
                            width: "85"
                        }), e(c, {
                            prop: "dynamic_content",
                            label: "笔记内容",
                            width: "210"
                        }, {
                            default: t(({row: s}) => [V("div", me, w(s.dynamic_content), 1)]),
                            _: 1
                        }), e(c, {prop: "user_id", label: "用户ID", width: "85"}), e(c, {
                            prop: "user.avatar",
                            label: "用户头像",
                            width: "90"
                        }, {
                            default: t(({row: s}) => [e(E, {
                                size: 50,
                                src: s.user && s.user.avatar ? s.user.avatar : ''
                            }, null, 8, ["src"])]), _: 1
                        }), e(c, {prop: "user.name", label: "昵称", width: "200"}), e(c, {
                            prop: "content",
                            label: "内容",
                            "min-width": "200",
                            "show-overflow-tooltip": ""
                        }), e(c, {prop: "ip_str", label: "IP归属地", "min-width": "100"}), e(c, {
                            prop: "status",
                            label: "状态",
                            width: "100"
                        }, {
                            default: t(({row: s}) => [e(T, {type: s.status == 0 ? "danger" : s.status == 1 ? "primary" : s.status == 2 ? "warning" : "info"}, {
                                default: t(() => [m(w(s.status == 0 ? "待审核" : s.status == 1 ? "正常" : s.status == 2 ? "违法违规" : "用户删除"), 1)]),
                                _: 2
                            }, 1032, ["type"])]), _: 1
                        }), e(c, {prop: "create_time", label: "评论时间", width: "180", sortable: ""}), e(c, {
                            label: "操作",
                            width: "160",
                            fixed: "right"
                        }, {
                            default: t(({row: s}) => [S((r(), f(g, {
                                link: "",
                                type: "success",
                                onClick: L => a("reply", s)
                            }, {
                                default: t(() => [m(" 回复 ")]),
                                _: 2
                            }, 1032, ["onClick"])), [[z, ["admin/dynamic.comment/create"]]]), S((r(), f(g, {
                                link: "",
                                type: "primary",
                                onClick: L => a("edit", s)
                            }, {
                                default: t(() => [m(" 编辑 ")]),
                                _: 2
                            }, 1032, ["onClick"])), [[z, ["admin/dynamic.comment/update"]]]), S((r(), f(g, {
                                link: "",
                                type: "danger",
                                onClick: L => I(s.id)
                            }, {
                                default: t(() => [m(" 删除 ")]),
                                _: 2
                            }, 1032, ["onClick"])), [[z, ["admin/dynamic.comment/delete"]]])]), _: 1
                        })]), _: 1
                    }, 8, ["data", "header-cell-style"]), V("div", _e, [e(P, {
                        modelValue: y(v),
                        "onUpdate:modelValue": d[4] || (d[4] = s => ee(v) ? v.value = s : null),
                        onChange: y(p)
                    }, null, 8, ["modelValue", "onChange"])])])), [[l, y(v).loading]])]), _: 1
                }), D.value ? (r(), f(ie, {
                    key: 0,
                    ref_key: "editRef",
                    ref: C,
                    onSuccess: y(p),
                    onClose: d[5] || (d[5] = s => D.value = !1)
                }, null, 8, ["onSuccess"])) : M("", !0)])
            }
        }
    };
export {fe as default};